package com.hyts.xmlparser.base.handler;

import com.hyts.xmlparser.constant.XmlEngineType;
import com.thoughtworks.xstream.XStream;
import lombok.Getter;

import java.io.File;

/**
 * project-name:coffice-toolbox
 * package-name:com.hyts.xmlparser.base.handler
 * author:Libo/Alex
 * create-date:2019-07-18 10:59
 * email:liboware@gmail.com
 * description:此类主要用于:
 */
public abstract class AbstractXmlTransferHandler<T extends Object> implements XmlTransferHandler<File,T>{
    /**
     * xml文件操作驱动引擎类型
     */
    XmlEngineType xmlEngineType;

    /**
     * Xstream操作流处理对象
     */
    @Getter
    XStream xStream;


    /**
     * xml文件的操作构造器服务对象方法
     */
    public AbstractXmlTransferHandler() {
        this(XmlEngineType.DEFAULT);
    }

    /**
     * @param xmlEngineType
     */
    public AbstractXmlTransferHandler(XmlEngineType xmlEngineType) {
        this.xmlEngineType = xmlEngineType;
        try {
            this.xStream = new XStream(xmlEngineType.getEngineDriverClass().newInstance());
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
